package com.kcs.fxmargin.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.kcs.common.utils.Constant;

public class LogoutAction extends FXAction {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
	
		try{
			System.out.println("LOGOUT [session] >> "+request.getSession());
			if(request.getSession()!=null){
				System.out.println("Before LOGOUT >> "+request.getSession().getAttribute(Constant.LOGIN_DATA_SESSION));
				request.getSession().invalidate();
				System.out.println("LOGOUT >> "+request.getSession().getAttribute(Constant.LOGIN_DATA_SESSION));
			}
			
		}catch(Exception e){
			e.printStackTrace();
			request.setAttribute(Constant.ERR_ATTR, e+"");
		}
		
		return mapping.findForward("login");
	}

	@Override
	public ActionForward process(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

}
